/***************************************************************
*
* DSDEQUE.H
*
* Contains interface of double-sided queue. Based on allocating objects in center.
***************************************************************/

#ifndef _DS_DEQUE_
#define _DS_DEQUE_

#include <assert.h>
#include <memory>
#include <stdio.h> //DEBUG

template <typename T> class dsDEQUE {
public:
                  dsDEQUE        (void);
                  dsDEQUE        (const dsDEQUE& src);
   explicit       dsDEQUE        (size_t allocated);
                  ~dsDEQUE       (void);

   T&             operator[]     (int idx);
   dsDEQUE&       operator=      (const dsDEQUE &src);

   void           PushFront      (const T& val);
   void           PushBack       (const T& val);
   void           Resize         (size_t new_size);
   void           Clear          (void);
   T&             PopFront       (void);
   T&             PopBack        (void);
   T&             GetFront       (void)   const;
   T&             GetBack        (void)   const;
   int            Find           (const T& item) const;
   bool           IsEmpty        (void)   const {return size == 0;}
   unsigned int   GetSize        (void)   const {return size;}
public: 
   void           ShowDebug      (void);
private:
   void           IncreaseFront  (size_t new_size);
   void           IncreaseBack   (size_t new_size);

   T              *buffer;
   size_t         head;
   size_t         tail;
   unsigned int   size;  
   size_t         allocated;
};

#include "ds_deque.hpp"

#endif //_DS_DEQUE_

//
// End-of-file DS_DEQUE.H
//